package main

import "fmt"

func main() {
	nums := []int{1, 2, 3, 4}
	target := 6
	result := twoSum(nums, target)
	fmt.Println(result)
}

func twoSum(nums []int, target int) []int {
	dict := map[int]int{}
	for i, v := range nums {
		if n, ok := dict[target-v]; ok {
			return []int{n, i}
		}
		dict[v] = i
	}
	return nil
}
